home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / qprint.asm < prev    next >
Assembly Source File  |  1985-06-03  |  4KB  |  136 lines

  1.                 page,132
  2.                 title QPRINT - 8088 routine CALLed from BASIC
  3. comment *            by Dan Rollins Byte, July, 1983
  4.         This routine prints a string to the video display at
  5.         ten times the speed of BASIC. Works for color or
  6.         monochrome in 80 or 40 column TEXT modes (no graphics),
  7.         Characters are displayed with the existing color,
  8.         blink and underline attributes,
  9.  
  10.         Called from BASIC via:
  11.  
  12.         CALL QPRINT(VAR$,ROW%,CLM%)
  13.  
  14.         Where:
  15.         CLM% is an integer variable name (1-80)
  16.         ROW% is an integer variable nmae (1-25)
  17.         VAR$ is a string variable name.
  18.  
  19.         VAR$ is displayed beginning at position CLM% of line
  20.             ROW%. If too long, it will wrap around to the next line.
  21.  
  22.         note: Color card pages 1-7 may be accessed by setting ROW% 
  23.         above 25.
  24.         *
  25. bios_data    segment at 40H            ;set up labels to determine
  26.             org 10H                    ;color or monochrome card
  27. equip_flag    label    word
  28.             org     4AH                ;40 or 80 column display
  29. crt_clms    label    word
  30.             org     63H
  31. addr_6845    label    word            ;points to video card ports
  32. bios_data ends
  33.  
  34. cseg     segment
  35.         assume CS:cseg, DS:nothing, ES:nothing
  36. ;
  37. ;Define the file header so that the Basic 
  38. ;BLOAD file loader will know what to do,
  39. ; ------   these bytes are not executed ------
  40. ;
  41. header:
  42.         db    0FDH                    ;indicated BLOAD file
  43.         dw    0                        ;segment - BASIC will use default
  44.         dw     0                        ;offset - secify in BLOAD command
  45.         dw    rtn_len                    ;length of the routine
  46.         page
  47. qprint    proc    far
  48.         push    es                    ;must save for basic
  49.         mov        bp,sp                ;point to arguments on stack
  50.         mov        bx,[bp+6]            ;get addr of CLM% storage
  51.         mov        di,[bx]                ;get the column value
  52.         dec        di                    ;adjust for LOCATE format
  53.  
  54.         mov        bx,[bp+8]            ;get addr of ROW% storage
  55.         mov        ax,[bx]                ;get the screen line value
  56.          dec        ax                    ;adjust for LOCATE format
  57.  
  58.         mov        bx,[bp+10]            ;get ptr to string descriptor
  59.         xor        ch,ch                ;zero the high byte
  60.         mov        cl,[bx]                ;get length of string
  61.         cmp        cl,0                ;null string?
  62.         je        exit                ;if so,do nothing, Else,
  63.         mov        si,[bx+1]            ;SI => 1st character of VAR$
  64.  
  65. ;
  66.         mov        bx,bios_data        ;get ready to determine card type
  67.         mov        es,bx                ;and number of columns
  68.         mul        es:crt_clms            ;AX = CLM% * words per line
  69.         add        di,ax                ;DI = words from start of screen
  70.         shl        di,1                ;adjust for attribute bytes
  71.  
  72.         mov        dx,es:addr_6845        ;point to 6845 base port
  73.         add        dx,6                ;point to status port
  74.  
  75. ;CX has the count of characters to write,
  76. ;SI points to the string data,
  77. ;DI points to a screen pointion
  78.         mov        ax,0B800H            ;default to color card
  79.         mov        bx,es:equip_flag
  80.         and        bx,30H
  81.         cmp        bx,30H                ;is it monochrome?
  82.         jne        card_ok                ;no, go
  83.         mov        ax,0B000H            ;yes, set for monochrome
  84. card_ok:
  85.         mov        es,ax                ;points ES to video
  86.  
  87. ;DS points to BASIC variables area
  88. ;ES points to video card memory
  89. ;Now display VAR$ on the screen.
  90.  
  91.         call    print_string
  92.  
  93. exit:
  94.         pop        es                    ;restore segment register
  95.         ret        6                    ;intersegment return,
  96.                                     ;clearing stack of 3 args
  97.  
  98. qprint    endp
  99.         page
  100.  
  101. ;this procedure displays a string of characters
  102. ;expects:
  103. ;        DS:SI => first character of string
  104. ;        ES:DI => screen memory to display it
  105. ;        CX    => number of characters to display
  106. ;        DX    => status port of video card
  107.  
  108. print_string    proc    near
  109.  
  110. ;-------- wait for horzontal retrace
  111. test_low:
  112.         in        al,dx                ;get status
  113.         test    al,1                ;is it low?
  114.         jnz        test_low            ;no, keep checking
  115.         cli                            ;turn off interrupts
  116.  
  117. test_hi:
  118.         in        al,dx                ;get status
  119.         test    al,1                ;is it high?
  120.         jz        test_hi                ;no, keep checking
  121.  
  122. ;-------- okay to write to screen now (no 'hash')
  123.  
  124.         movsb    ;[DS:DI]->[ES:DI],DI++,SI++,CX--
  125.  
  126.         inc        di                    ;skip the attribute byte
  127.         loop    test_low            ;do till end of string
  128.         sti                            ;turn interrupts back on
  129.         ret                            ;back to qprint proc
  130.  
  131. print_string endp
  132.  
  133. rtn_len    equ        $ -qprint            ;define length for BLOAD header
  134. cseg     ends    
  135.         end        header                ;needed for BIN file conversion
  136.